import { request } from './request'

export const getLogin = params => {
  return request.post('/login', { ...params, permission: '2' })
}

export const getRegist = params => {
  return request.post('/register', params)
}

export const getUserAll = params => {
  return request.get('/admin/getAllUser', {
    params
  })
}

export const findUsername = params => {
  return request.post('/users/findUsername', params)
}

export const deletUser = params => {
  return request.delete('/user/deleteUser', params)
}

export const upUserinfo = params => {
  return request.post('/user/updateUserById', params)
}
export const findUserInfo = params => {
  return request.post('/users/getUserInfo', params)
}

export const editUserpass = params => {
  return request.post('/users/editUserpass', params)
}

export const getBookAll = params => {
  return request.get('/book/getListByPage', {
    params
  })
}

export const getBookPageList = params => {
  return request.get('/book/getListByPage', {
    params
  })
}

export const updateBook = params => {
  return request.post('/book/updateBook', params)
}

export const selectBookById = params => {
  return request.get('/book/selectBookById', {
    params
  })
}

export const deleteBookId = params => {
  return request.delete('/book/deleteBook', {
    params
  })
}

export const addBook = params => {
  return request.post('/book/addBook', params)
}
export const getBorrowAll = params => {
  return request.get('/admin/selectBorrowBook', {
    params
  })
}

export const getBorrowPageList = params => {
  return request.get('/admin/selectBorrowBook', {
    params
  })
}

export const updateBorrow = params => {
  return request.post('/admin/updateBorrowBook', params)
}

export const deleteBorrow = params => {
  return request.post('/admin/deleteBorrowBook',
    params
  )
}

export const DataCount = () => {
  return request.get('/user/rankingByOneDay')
}

export const ranking = () => {
  return request.get('/user/ranking')
}

export const rankingPeasonByOneDay = () => {
  return request.get('/user/rankingPeasonByOneDay')
}

export const rankingPeason = () => {
  return request.get('/user/rankingPeason')
}
export const getNotice = () => {
  return request.get('/user/getNotice')
}
export const updateNotice = (params) => {
  return request.post('/notice/updateNotice', params)
}
export const addNotice = (params) => {
  return request.post('/notice/addnotice', params)
}

export const deleteNotice = (par) => {
  return request.delete('/notice/deleteNotice', {
    params: {
      noticeId: par
    }
  })
}
